home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / XCMDs and XFCNs / OptionKeyDown XFCN 1.0.0 / OptionKeyDown.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-20  |  986 b   |  52 lines  |  [TEXT/MPS ]

  1. /* ----------------------------------------------------------------------
  2.  
  3.     OptionKeyDown XFCN
  4.     version 1.0
  5.     27 September 1993
  6.     
  7.     Written by: Paul Celestin
  8.     
  9.     Copyright © 1993 Celestin Company
  10.     All Rights Reserved
  11.     
  12.     This XFCN returns true if the option key is down.
  13.     
  14.     930927 - 1.0.0 - initial release
  15.  
  16. ---------------------------------------------------------------------- */
  17.  
  18. # include    <Events.h>
  19. # include    <HyperXCMD.h>
  20. # include    <OSUtils.h>
  21. # include    <QuickDraw.h>
  22. # include    <Traps.h>
  23. # include    <SetUpA4.h>
  24.  
  25. Boolean bit_test(Ptr p, int n)
  26. {
  27.     return(!!(p[n/8] & 1L<<(n%8)));
  28. }
  29.  
  30. pascal void main(XCmdPtr paramPtr)
  31. {
  32.     long            it;
  33.     StringPtr        myString;
  34.     KeyMap            myKeys;
  35.     Boolean            isTrue;
  36.  
  37.      RememberA0();
  38.      SetUpA4();
  39.      
  40.     if (paramPtr->paramCount == 0)
  41.     {
  42.         GetKeys(myKeys);
  43.         if (bit_test((Ptr)myKeys, 0x3a)) /* 0x3a is the option key */
  44.             paramPtr->returnValue = PasToZero(paramPtr,"\ptrue");
  45.         else
  46.             paramPtr->returnValue = PasToZero(paramPtr,"\pfalse");
  47.     }
  48.     
  49.     RestoreA4();
  50. }
  51.  
  52.